import sys

def dealsize():
    taxSizeList = '/home/yong_sun/bin/workflow/tax2size.list'
    with open(taxSizeList) as t2s:
        d = {}
        for i in t2s:
            tax, size = i.split()
            d[tax] = int(size)
        return d


def main(kk):
    taxSize = dealsize()

    with open(kk) as kf:
        header = kf.readline().split()
        sCol = []
        for i, e in enumerate(header):
            if e.find('S') != -1:
                sCol.append(i)
        for i in kf:
            info = i.split()
            length = 0
            for i, e in enumerate(sCol[::-1]):
                if info[e] != '-':
                    if length == 0:
                        sid = info[e].split('_')[1]
                        print(f'{sid}\t{taxSize[sid]}')
                        length = taxSize[sid]
                    else:
                        sid = info[e].split('_')[1]
                        print(f'{sid}\t{length}')


if __name__ == "__main__":
    main(sys.argv[1])
